package com.kb.design.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.annotation.IEnum;
import com.google.common.base.Objects;

/**
 * @Auther:chenzx
 * @Date:2024-01-30
 * @Description:项目状态枚举
 */
public enum DesignStatus {
    /**
     * 封装
     * 设计
     * 检查
     * 投板
     * 入库
     * 奖金分配
     * 奖金确认
     * 完成
     */
    STOP("暂停", "0"),
    ENCAPSULATION("封装", "10"),
//    AWAIT_ASSIGN("待指派", "15"),
    DESIGN("设计", "20"),
    CHECK("检查", "25"),
    CASTING_BOARD("交付", "30"),
//    WAREHOUSING("入库", "35"),

    BONUS_DISTRIBUTION("奖金分配", "40"),
    Leader_BONUS_DISTRIBUTION("奖金分配", "43"),
    WAITING_BONUS_CONFIRMATION ("奖金确认", "44"), //参与人员确认完的状态
    BONUS_CONFIRMATION ("奖金确认", "45"), //等客服确认
    FINISH("完成", "50"),
    DRAFT("草稿", "100");
    // 成员变量

    private String name;
    @EnumValue
    private String index;

    public DesignStatus next() {
        DesignStatus[] statuses = DesignStatus.values();
        int ordinal = this.ordinal();
        if (ordinal < statuses.length - 1) {
            return statuses[ordinal + 1];
        } else {
            return null; // 处理逻辑，表示已是最后一个状态
        }
    }

    public static DesignStatus getNextStatusByIndex(int index) {
        for (DesignStatus status : DesignStatus.values()) {
            if (Integer.parseInt(status.index) == index) {
                return status.next();
            }
        }
        return null; // 如果没有找到对应状态，返回null
    }

    // 构造方法
    DesignStatus(String name, String index) {
        this.name = name;
        this.index = index;
    }

    // 普通方法
    public static String getName(String index) {
        for (DesignStatus c : DesignStatus.values()) {
            if (Objects.equal(index, c.getIndex())) {
                return c.name;
            }
        }
        return null;
    }

    // get set 方法
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getIndex() {
        return index;
    }

    public void setIndex(String index) {
        this.index = index;
    }
}
